package com.bupt.liutong.admin.groupon.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.beans.factory.annotation.Autowired;

import com.bupt.liutong.admin.core.base.BaseAction;
import com.bupt.liutong.admin.groupon.bo.CityBo;
import com.bupt.liutong.admin.groupon.dao.GrouponDao;

public class GrouponAction extends BaseAction {

	@Autowired
	private GrouponDao grouponDao;

	@Autowired
	private CityBo cityBo;

	/**
	 * Constructor of the object.
	 */

	public ActionForward userVisit(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		/*
		List<Groupon> groupons = grouponDao.getGrouponByCityId(cityId);

		request.setAttribute("groupons", groupons);
		request.setAttribute("cityId", cityId);
		request.setAttribute("uid", uid);
		*/
		return mapping.findForward("grouponList");
	}

	public ActionForward changeCity(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		/*
		// uid is the baidu id of the visitor
		String uid = request.getParameter("uid");
		int cityId = Integer.valueOf(request.getParameter("cityId"));
		Cookie c = new Cookie("baiducity", "" + cityId);
		c.setMaxAge(60*60*24*365);
		response.addCookie(c);
		if (uid != null && uid.length() != 0) {
			cityBo.updateUser(uid, cityId);
		}
		List<Groupon> groupons = grouponDao.getGrouponByCityId(cityId);
		request.setAttribute("groupons", groupons);
		request.setAttribute("cityId", cityId);
		request.setAttribute("uid", uid);
		*/
		return mapping.findForward("grouponList");
	}

	public GrouponDao getGrouponDao() {
		return grouponDao;
	}

	public void setGrouponDao(GrouponDao grouponDao) {
		this.grouponDao = grouponDao;
	}

	public CityBo getCityBo() {
		return cityBo;
	}

	public void setCityBo(CityBo cityBo) {
		this.cityBo = cityBo;
	}

}
